home *** CD-ROM | disk | FTP | other *** search
Wrap
2 ' $TITLE:'WSCONV.BAS -- WSCONV.EXE (Orig:WS-DOS)' $SUBTITLE:'CONVERTS WORDSTAR& ASCII FILES, ONE TO THE OTHER.' $LINESIZE: 97 $PAGESIZE: 63 Compiler: /o/e 4 ' BY ANDREW FLUEGELMAN: (C)1983 The Headlands Press. 6 ' Modified by Jim Gainsley, Mpls.,MN. (c)1983 (Added in L1070:'OR L$="" and L2125 'PRINT #2,L$. First to provide hard cr for blank lines. 2nd to write last line to file if no cr. Also, Choice for Soft & Hard CRLF on AS->WS. 8 QST$=" ? in response to request for filename gives files on default drive. You may also use any Basic filename call commands. To exit after filename is requested, press ENTER. WILL OVERWRITE EXISTING FILES! 10 DEFINT A-Z:ON ERROR GOTO 9000 15 A=0:A$="":L$="":P=0:ST=0 'Optimizes key variables 20 CRLF$=CHR$(13)+CHR$(10):HBLF$=CHR$(141)+CHR$(10) ' Hard & Soft CR/LF 25 SP$=CHR$(32):TB$=CHR$(9) ' Space & Tab 30 SH$=CHR$(31):PB$=CHR$(20) ' Soft hyphen & placebo 35 DT=19:DIM D$(19): FOR P=1 TO DT: READ D$(P):NEXT 'Read dot commands 40 EN=4: DIM EN(4),ENO$(4),ENC$(4),MRK(4) 'Read enhancement symbols 45 FOR P=1 TO EN: READ EN(P),ENO$(P),ENC$(P):MRK(P)=0:NEXT 50 KEY OFF:CLS 60 LOCATE 10,5:COLOR 15,0:PRINT"PROGRAM TO CONVERT WORDSTAR FILES TO ASCII AND ASCII FILE TO WORDSTAR.":PRINT:LOCATE ,5 80 PRINT"Original program by Andrew Fleugelman, with extensions by Jim Gainsley":LOCATE ,4:PRINT"Copyright 1983, 1984. Licensed for distribution as Public Domain Software.":PRINT: PRINT 82 PRINT SPC(15)"...ah let's see... yeah, this is version 2.0":SOUND 32000,30:SOUND 32000,1:COLOR 7,0:CLS 103 PRINT QST$:PRINT:PRINT 105 PRINT" ======== CONVERT ======== 110 PRINT 115 PRINT" 1 - ASCII to WORDSTAR 120 PRINT" 2 - WORDSTAR to ASCII 900 PRINT" X = exit 905 PRINT 910 BYT#=0:LOCATE ,10:PRINT"Choose: "; 915 INPUT "",Q$: IF Q$="x" OR Q$="X" THEN SYSTEM 920 ON VAL(Q$) GOTO 1000,2000 925 BEEP:GOTO 103 930 ' 1000 CLS 1003 PRINT QST$:PRINT:PRINT 1005 PRINT" ==== ASCII-to-WORDSTAR CONVERTER ====" 1010 PRINT 1015 PRINT"This routine will convert a standard DOS file into the format 1020 PRINT" required by WordStar for paragraph reforming by converting 1025 PRINT" 'hard' carriage returns (ASCII 13) into 'soft' CR's (ASCII 141). 1030 PRINT:PRINT"If file contains blank lines between paragraphs or indented 1035 PRINT" paragraphs, hard returns will be preserved at each paragraph end. 1040 PRINT 1042 PRINT:PRINT"If line FOLLOWING the CURRENT line BEGINS with space(s) or tab(s) then:":PRINT 1043 PRINT" 1. Provide Hard CR/LF at end of CURRENT line. 1044 PRINT" 2. Provide SOFT CR/LF at end of CURRENT line. 1045 PRINT:PRINT" (Note: Option 2 will allow a reformattable structure for indented sections.)":PRINT 1046 INPUT" Enter Choice (1/2 [3=exit]): ";ST:IF ST<1 OR ST>3 THEN BEEP:GOTO 1046 ELSE IF ST=2 THEN ST=-1 ELSE IF ST=3 THEN 103 1048 GOSUB 8000: IF FL$="" THEN 103 1050 PRINT:PRINT"Conversion in progress... BYTES PROCESSED: ";:CS=CSRLIN: PS=POS(0) 1055 IF EOF(1) THEN 8045 ELSE LINE INPUT #1,L$ 'First line of file only. 1057 IF EOF(1) AND ST THEN GOSUB 1100 1060 IF EOF(1) THEN PRINT #2,L$+CRLF$;:GOSUB 1250:GOTO 8045 1065 LINE INPUT #1,A$ 1070 IF A$="" OR L$="" THEN IF ST AND A$="" AND L$<>"" THEN GOSUB 1100:GOTO 1090 ELSE 1090 'Test for blank line 1072 IF ST THEN GOSUB 1100:GOTO 1085 1075 IF LEFT$(A$,2)=SP$+SP$ THEN 1090 ' Test for indent 1080 IF LEFT$(A$,1)=TB$ THEN 1090 ' Also test for Tab 1085 PRINT #2,L$+HBLF$;:GOSUB 1250:L$=A$:GOTO 1057 'Write line with soft CR 1090 PRINT #2,L$+CRLF$;:GOSUB 1250:L$=A$:GOTO 1057 'Write line & hard CR. 1095 ' 1099 ' Routine to replace spaces 20h with high byte space A0h. 1100 S$="":S1$="":SL=1 1110 S$=MID$(L$,SL,1):IF S$<>SP$ THEN 1140 1120 S1$=S1$+S$:SL=SL+1:GOTO 1110 1140 IF S1$<>"" THEN FOR J=1 TO LEN(S1$): MID$(L$,J)=CHR$(160):NEXT 1150 RETURN 1250 LOCATE CS,PS:BYT#=BYT#+LEN(L$)+2:PRINT BYT#;:RETURN 'Byte counter 2000 CLS 2003 PRINT QST$:PRINT:PRINT 2005 PRINT" ===== WORDSTAR-to-ASCII CONVERTER ===== 2010 PRINT 2015 PRINT"This routine converts a WordStar 'Document' file 2020 PRINT" into standard DOS format. All 'high bit' characters 2025 PRINT" are converted to their 'low bit' equivalents. 2030 PRINT"All 'soft' hyphens are stripped, except that any hyphens 2035 PRINT" at end of lines are retained. 2040 PRINT 2045 PRINT"You can either strip or retain lines that contain dot commands. 2050 PRINT"As another option, you can either strip all print enhancements 2055 PRINT" or replace certain enhancement codes as follows: 2060 PRINT 2065 PRINT" underline (^S) becomes << ... >> 2070 PRINT" boldface (^B) becomes <<< ... >>> 2075 PRINT" superscript (^T) becomes <^ ... ^> 2080 PRINT" subscript (^V) becomes <_ ... _> 2085 PRINT 2090 PRINT :INPUT"Strip or Retain dot commands (s/r): ",Q$ 2095 IF Q$="S" OR Q$="s" THEN STRIPDOT=-1 ELSE STRIPDOT=0 2100 INPUT"Strip or Replace print enhancements (s/r): ",Q$ 2105 IF Q$="R" OR Q$="r" THEN ENHANCE=-1 ELSE ENHANCE=0 2110 GOSUB 8000: IF FL$="" THEN 103 2115 PRINT:PRINT"Conversion in progress... BYTES PROCESSED: ";:CS=CSRLIN: PS=POS(0) 2120 L$="" 2125 IF EOF(1) AND L$<>""THEN PRINT #2,L$:BYT#=BYT#+LEN(L$)+2:LOCATE CS,PS:PRINT BYT#;:GOTO 8045 'Print last file line if no crlf. 2126 IF EOF(1) THEN 8045 ELSE A$=INPUT$(1,#1):A=ASC(A$):IF A>30 AND A<128 THEN L$=L$+A$:GOTO 2125 'Soft hyphen or normal ASCII, proceed 2130 IF A>127 THEN A=A-128:A$=CHR$(A) 'Convert to low-bit character 2135 IF A>31 THEN L$=L$+A$:GOTO 2125 'Now if normal ASCII, proceed 2140 IF A=13 THEN GOSUB 2170:A$=INPUT$(1,#1):GOTO 2120'eol, process & remove LF 2145 IF NOT ENHANCE THEN 2125 2150 ' Deal with enhancements 2155 FOR P=1 TO EN:IF A<>EN(P) THEN 2165 'Find special characters 2160 IF MRK(P) THEN L$=L$+ENC$(P):MRK(P)=0 ELSE L$=L$+ENO$(P):MRK(P)=-1 'Convrt 2165 NEXT: GOTO 2125 2170 ' Subroutine to strip soft hyphens and dot commands 2175 P=INSTR(L$,SH$):IF P=0 OR P>=LEN(L$)-1 THEN 2180 ELSE L$=LEFT$(L$,P-1)+ RIGHT$(L$,LEN(L$)-P):GOTO 2175 'Strip soft hyphens 2180 IF RIGHT$(L$,1)=SH$ THEN MID$(L$,LEN(L$),1)="-" 'Except at eol 2185 ' 2190 IF STRIPDOT AND (LEFT$(L$,1)=".") THEN 2200 'Possible dot command? 2195 PRINT #2,L$:BYT#=BYT#+LEN(L$)+2:LOCATE CS,PS:PRINT BYT#;:RETURN 'Write line to disk. 2200 B$=MID$(L$,2,1):A=ASC(B$):IF A>64 AND A<91 THEN A=A+32:B$=CHR$(A) 2205 C$=MID$(L$,3,1):A=ASC(C$):IF A>64 AND A<91 THEN A=A+32:C$=CHR$(A) 2210 DUMP=0:FOR P=1 TO DT:IF B$+C$=D$(P) THEN DUMP=-1 'Search for dot command 2215 NEXT: IF DUMP THEN RETURN ELSE GOTO 2195 'Dump line if dot command 2220 ' 8000 ' File specs 8005 INPUT"File to Convert:",FL$: IF FL$="" THEN RETURN 8010 IF LEFT$(FL$,1)="?" THEN GOSUB 8035:GOTO 8005 8015 OPEN FL$ FOR INPUT AS #1 8020 INPUT"Convert to file:",FL$: IF FL$="" THEN 8005 8025 IF LEFT$(FL$,1)="?" THEN GOSUB 8035:GOTO 8020 8030 OPEN FL$ FOR OUTPUT AS #2: RETURN 8035 IF LEN(FL$)>1 THEN FL$=RIGHT$(FL$,LEN(FL$)-1) ELSE FL$="*.*" 8040 PRINT :FILES FL$:PRINT :RETURN 8045 CLOSE:BEEP:PRINT:PRINT"Done!": GOTO 105 8050 ' 9000 ' Error trapping 9005 IF ERL=8015 THEN CLOSE:BEEP:PRINT "==== Filespec Error ====":RESUME 8005 9010 IF ERL=8030 THEN CLOSE 2:BEEP:PRINT "==== Filespec Error ====":RESUME 8020 9015 IF ERL=8040 THEN CLOSE:BEEP:PRINT "=== File(s) not Found ===":RESUME 8005 9020 ON ERROR GOTO 0 9025 ' 10000 DATA bp,uj,po,cw,ig,cp,fo,fm,he,hm,lh,mb,mt,pa,op,pn,pc,sr,pl 10005 DATA 19,"<<",">>" 10010 DATA 2,"<<<",">>>" 10015 DATA 22,"<_","_>" 10020 DATA 20,"<^","^>"